﻿CREATE FUNCTION QIC.InterfaceTokenCall(@Token QIC.TokenTable READONLY, @ObjectId INT, @TokenMap VARCHAR(50))
RETURNS VARCHAR(MAX)
AS
BEGIN

	DECLARE @Parameters VARCHAR(MAX)

	SET @Parameters = ''

	SELECT @Parameters += 
		QIC.TokenSubstitute(@Token, PropertyName, @TokenMap)
		+ case IsOutPut when 1 then ' OUT' else '' end
		+ ', '
	FROM @Token
	WHERE ObjectId = @ObjectId
	AND PropertyId > 0
	ORDER BY PropertyId

	IF @Parameters <> '' SET @Parameters = LEFT(@Parameters,DATALENGTH(@Parameters) - 2)

	RETURN @Parameters

END

